﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nardax.ServiceModel.Discovery;
using Nardax.Samples.ServiceContracts;

namespace Nardax.Samples.DiscoverableServicesClient
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var dsp = new DiscoverableServiceProxy<IDiscoverableService>())
            {
                dsp.ScopeMatchBy = DiscoverableServiceProxy<IDiscoverableService>.ScopeMatchByPartialPair;
                dsp.Scopes.Add(new Uri("http://service/c/3"));
                dsp.OpenAnnouncementService();
                dsp.DiscoverAvailableServices();

                Console.WriteLine("Press <ENTER> to call services once.");
                Console.ReadKey();
                dsp.Call(x => x.DoWork("Hello from client!"));

                Console.WriteLine("Press <ENTER> to call services 100 times.");
                Console.ReadKey();

                for (var i = 0; i < 100; i++)
                {
                    var value = i.ToString();
                    dsp.Call(x => x.DoWork(value));
                }

                Console.ReadKey();
            }
        }
    }
}
